//AC
#include <iostream>
#include <cmath>
#define ll long long

using namespace std;

int main(){
    int n;
    cin>>n;
    while (n--){
        ll a,b;
        cin>>a>>b;
        ll diff = abs(a*a-b*b);
        ll ans = 0;
        ans += (diff-1)/2;
        ans += (diff-4)/4;
        cout<<ans<<endl;
    }

	return 0;
}

